package org.jackysoft.struts2.workflow;

import org.apache.struts2.convention.annotation.Namespace;
import org.jackysoft.data.TransferProtocol;
import org.jackysoft.service.WorkflowService;
import org.jackysoft.util.WorkflowConstant;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;


/*******************************************************************************
 * 根据用户需求查找相关的工作流 将结果返回给成功页面
 * 
 * @author SERVER56
 * 
 */
@Controller
@Namespace("/workflow/data")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class QueryDataAction extends WorkflowItemAction{
	private static final long serialVersionUID = -596208082445505695L;
    private TransferProtocol protocol =  TransferProtocol.json;
	
	public String inbox() throws Exception {
		
		
		WorkflowService.LOCAL_STATUS.set(WorkflowConstant.STATE_UNDERWAY);
		getJson();
		this.pager.setActionClass(this.getClass());
		this.pager.setMethod("inbox");
		return protocol==TransferProtocol.json?JQGRID:"inbox";
	}
	

	public String older() throws Exception {
		WorkflowService.LOCAL_STATUS.set(WorkflowConstant.STATE_FINISHED);
		getJson();
		this.pager.setActionClass(this.getClass());
		this.pager.setMethod("older");
		return protocol==TransferProtocol.json?JQGRID:"older";
	}

	public String watch() throws Exception {
		WorkflowService.LOCAL_STATUS.set(WorkflowConstant.STATE_WATCHOR);
		WorkflowService.CURRENT_WORKFLOWID.set(getWorkflowId());
		getJson();		
		return protocol==TransferProtocol.json?JQGRID:"watch";
	}


	public String current() throws Exception {
		WorkflowService.LOCAL_STATUS.set(WorkflowConstant.ALL_CURRENT);
		getJson();
		return protocol==TransferProtocol.json?JQGRID:"current";
	}


	public String history() throws Exception {
		WorkflowService.LOCAL_STATUS.set(WorkflowConstant.ALL_HISTORY);
		getJson();
		return protocol==TransferProtocol.json?JQGRID:"history";
	}

	public TransferProtocol getProtocol() {
		return protocol;
	}

	public void setProtocol(TransferProtocol protocol) {
		this.protocol = protocol;
	}

}
